import axios from '@/libs/api.request'
import { getToken } from '@/libs/util'


class Channel {
  constructor() {
    this.$axios = axios;
  }

  /**
   * 分页查询通道
   * @param param
   * @returns {*}
   */
  queryChannelPage = (param) => {
    return axios.request({
      url: '/admin/channel/query/page/',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    })
  }

  /**
   * deviceCode
   * @param deviceCode
   * @returns {*}
   */
  channelSync = (deviceCode) => {
    return axios.request({
      url: '/admin/channel/'+deviceCode+'/sync/',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      //data: param
    })
  }

  /**
   * 通道新增
   * @param param
   * @returns {*}
   */
  addChannel = (param) => {
    return axios.request({
      url: '/admin/channel/add/',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    })
  }

  /**
   * 通道修改
   * @param param
   * @returns {*}
   */
  updateChannel = (param) => {
    return axios.request({
      url: '/admin/channel/update/',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    })
  }

  /**
   * 通道删除
   * @param param
   * @returns {*}
   */
  removeChannel = (param) => {
    return axios.request({
      url: '/admin/channel/delete/',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    })
  }
}
export default Channel;







/*


export const queryChannelPage = (param) => {
  return axios.request({
    url: '/admin/channel/query/page/',
    method: 'post',
    dataType: 'json',
    headers: {
      'Content-Type': 'application/json; charset=UTF-8',
      'token': getToken()
    },
    data: param
  })
}

*/

